//
//  BJLoginViewController.m
//  DangXiao
//
//  Created by APPLE on 16/12/8.
//  Copyright © 2016年 APPLE. All rights reserved.
//

#import "BJLoginViewController.h"
#import "BJLabelAndLineView.h"
#import "BJTextAndLineView.h"
#import "BJForgetPassViewController.h"

@interface BJLoginViewController ()

@end

@implementation BJLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"登录";

    
    
}

static BJTextAndLineView *nameView;
static BJTextAndLineView *passView;
static UIButton *loginBtn;
static UIButton *forgetPassBtn;

-(void)initUI{
    UIImageView *signImageView = [[UIImageView alloc]init];
    signImageView.backgroundColor = BaseColor;
    [self.view addSubview:signImageView];
    [signImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.top.mas_equalTo(BILIHEIGHT(50) + 64);
        make.size.mas_equalTo(CGSizeMake(BILIWIDTH(80), BILIWIDTH(80)));
    }];
    

    
    UIImageView *nameImageView = [[UIImageView alloc]init];
    nameImageView.backgroundColor = BaseColor;
    [self.view addSubview:nameImageView];
    [nameImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(BILIWIDTH(30));
        make.top.mas_equalTo(BILIHEIGHT(50 + 120) + 64);
        make.size.mas_equalTo(CGSizeMake(BILIWIDTH(25), BILIWIDTH(28)));
    }];
    
    
   nameView  = [[BJTextAndLineView alloc]init];
    nameView.nameTF.clearButtonMode = YES;
    [self.view addSubview:nameView];
    [nameView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(nameImageView.mas_right).offset(BILIWIDTH(10));
        make.top.equalTo(nameImageView);
        make.right.mas_equalTo(-BILIWIDTH(30));
        make.height.mas_equalTo(BILIHEIGHT(30));
    }];
    
    UIImageView *passImageView = [[UIImageView alloc]init];
    passImageView.backgroundColor = BaseColor;
    [self.view addSubview:passImageView];
    [passImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(BILIWIDTH(30));
        make.top.mas_equalTo(BILIHEIGHT(50 + 170) + 64);
        make.size.mas_equalTo(CGSizeMake(BILIWIDTH(25), BILIWIDTH(28)));
    }];
    
    passView = [[BJTextAndLineView alloc]init];
    passView.nameTF.placeholder = @"请输入密码";
    passView.nameTF.secureTextEntry = YES;
    passView.nameTF.clearButtonMode = YES;

    [self.view addSubview:passView];
    [passView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(passImageView.mas_right).offset(BILIWIDTH(10));
        make.top.equalTo(passImageView);
        make.right.mas_equalTo(-BILIWIDTH(30));
        make.height.mas_equalTo(BILIHEIGHT(30));
    }];
    
    loginBtn = [Utils createBtnWithType:(UIButtonTypeCustom) backgroundColor:BaseColor title:@"登录" image:nil font:15];
    [self.view addSubview:loginBtn];
    [loginBtn addTarget:self action:@selector(didClickLoginBtn:) forControlEvents:(UIControlEventTouchUpInside)];
    BJViewBorderRadius(loginBtn, 3, 1.0, ClearColor);
    [loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(BILIWIDTH(30));
        make.top.equalTo(passView.mas_bottom).offset(BILIHEIGHT(35));
        make.right.mas_equalTo(-BILIWIDTH(30));
        make.height.mas_equalTo(BILIHEIGHT(35));
    }];
    
    forgetPassBtn = [Utils createBtnWithType:(UIButtonTypeCustom) backgroundColor:ClearColor title:@"忘记密码?" image:nil font:15];
    [forgetPassBtn setTitleColor:GrayTextColor forState:(UIControlStateNormal)];
    [self.view addSubview:forgetPassBtn];
    [forgetPassBtn addTarget:self action:@selector(didClickForgetPassBtn:) forControlEvents:(UIControlEventTouchUpInside)];
    [forgetPassBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.top.equalTo(loginBtn.mas_bottom).offset(BILIHEIGHT(15));
        make.size.mas_equalTo(CGSizeMake(BILIWIDTH(100), BILIHEIGHT(20)));
    }];
}

#pragma mark ---- 点击“登录”按钮
- (void)didClickLoginBtn:(UIButton *)btn{
    
}

#pragma mark ---- 点击“忘记密码”按钮
- (void)didClickForgetPassBtn:(UIButton *)btn{
    BJForgetPassViewController *VC = [[BJForgetPassViewController alloc]init];
    [self.navigationController pushViewController:VC animated:YES];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [nameView.nameTF resignFirstResponder];
    [passView.nameTF resignFirstResponder];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



@end
